home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9777 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.clark.net!not-for-mail
  2. From: gusty@clark.net (Harlan Messinger)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Leap year
  5. Date: 4 Mar 1996 13:48:26 GMT
  6. Organization: Clark Internet Services, Inc., Ellicott City, MD USA
  7. Message-ID: <4hesba$ph@clarknet.clark.net>
  8. References: <3135A7F2.2120@hiwaay.net> <4hbiln$899@sam.inforamp.net>
  9. NNTP-Posting-Host: explorer.clark.net
  10. Mime-Version: 1.0
  11. Content-Type: TEXT/PLAIN; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
  14.  
  15. Randy Charles Morin (rmorin@inforamp.net) wrote:
  16. : In article <3135A7F2.2120@hiwaay.net>, Lance Perry <lperry@hiwaay.net> wrote:
  17. : >Can someone be kind enough to post the formula for Leap Year
  18. : >or point me to the place where this can be found?
  19. : >
  20. : >lperry@hiwaay.net
  21. : bool IsLeapYear(int x)
  22. : {
  23. :     return ((x&4) && ((!(x&100)) || (x&1000)));
  24. : }
  25. : I hope I got everything right.
  26. : Agrivar
  27.  
  28. Sorry, you didn't. (x&4) does not tell you whether x is divisible by 4. 
  29. (x&4) returns TRUE, for example, for 5, 6 and 7, none of which is
  30. divisible by 4. And so on for 100 and 1000. And anyway, the third magic
  31. number is 400, not 1000. 
  32.  
  33.